In [35]:
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
import numpy.lib.recfunctions as nlr
%matplotlib inline
Firstly import csv and open the csv file.
In [36]:
import csv
file = open('public_layout.csv','r')
In [37]:
reader = csv.reader(file, delimiter=',')
In [38]:
fullcsv = list(reader)
Create an empty dictionary and for each variable whose absolute value of correlation coefficient with the heating space energy consumption is greater than 0.35 we use the dictionary to store the position of this variable and the correlation coefficient.
In [39]:
dic_1=dict()
print(dic_1)
for i in range(801):
data = np.genfromtxt('recs2009_public.csv',delimiter=',',skip_header=1,usecols=(i,908))
coef = np.corrcoef(data[:,0],data[:,1])
if abs(coef[0][1])>=0.35:
dic_1[i]=coef[0][1]
print(dic_1)
Sort the dictionary according to their values of correlation coefficient.
In [40]:
import operator
sortedDic=sorted(dic_1.items(), key=operator.itemgetter(1))
sortedDic
Out[40]:
I will print the indices and correlation coefficient of variables we will use in our model besides materials.
In [42]:
variables_chosen=[6, 315, 430, 705]
print(sortedDic[-2])
print(sortedDic[8])
print(sortedDic[6])
After selecting the most influential variables,we will construct the design matrix for these variables and variable of 'WALLTYPE' whcih is material for outer wall.